home *** CD-ROM | disk | FTP | other *** search
- //
- // File: InstaCompOneScriptCheckExt.c
- //
- // This file contains the source code for the DirectCopy File/Resource Info
- // ScriptCheck extension function. Since our source files are in the regular
- // format (not compressed or otherwise changed and unreadable by normal
- // means) we can get the information we need directly from them. If you are
- // writing your own ScriptCheck extension for your own file format, you will
- // need to provide routines that know how to read your file format.
- //
- // Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
- //
- //
-
-
- #include "TargetInfoMgt.h"
-
- #include <Errors.h>
- #include <Files.h>
- #include <Resources.h>
-
-
- OSErr main( TargetInfoPBPtr theTargetInfoPBPtr )
- {
- OSErr theErr = noErr;
- short savedResFile = CurResFile();
- short resAttrs;
- long resSize;
- Handle theResourceHdl;
- SInt16 fileRefNum;
- CInfoPBRec theCatInfo;
-
-
-
- if( theTargetInfoPBPtr->fFileInfo.fSrcDataType // If we are looking at a resource
- == kDataTypeIsRsrc )
- {
- // open source file to make it cur res file
- fileRefNum = HOpenResFile( theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.vRefNum,
- theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.parID,
- theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.name,
- fsRdPerm );
- theErr = ResError();
- if (theErr != noErr) return theErr;
- // get a handle to our resource
- theResourceHdl = Get1Resource( theTargetInfoPBPtr->fRsrcInfo.fSrcRsrcType,
- theTargetInfoPBPtr->fRsrcInfo.fSrcRsrcID);
-
- theErr = ResError();
- if (theErr != noErr) return theErr;
-
- resAttrs = GetResAttrs( theResourceHdl ); // get the resource attributes
-
- theErr = ResError();
- if (theErr != noErr) return theErr;
-
- resSize = GetResourceSizeOnDisk( theResourceHdl ); // get resource size
-
- theErr = ResError();
- if (theErr != noErr) return theErr;
-
- theTargetInfoPBPtr->fRsrcInfo.fTgtRsrcAttrs = resAttrs;
- theTargetInfoPBPtr->fRsrcInfo.fTgtRsrcSize = resSize;
-
- CloseResFile( fileRefNum );
- UseResFile( savedResFile );
- }
- else // we're getting file info
- {
- theCatInfo.hFileInfo.ioFDirIndex = 0; // use ioNamePtr and ioDirID
- theCatInfo.hFileInfo.ioDirID =
- theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.parID; // the file's parent directory
- theCatInfo.hFileInfo.ioNamePtr =
- theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.name; // filename
- theCatInfo.hFileInfo.ioVRefNum =
- theTargetInfoPBPtr->fFileInfo.fSrcFSSpec.vRefNum; //
-
- theErr = PBGetCatInfoSync(&theCatInfo); // get info about our file
-
- if (theErr == noErr )
- {
- theTargetInfoPBPtr->fFileInfo.fTgtFinderAttrs = // finder attributes
- theCatInfo.hFileInfo.ioFlAttrib;
- theTargetInfoPBPtr->fFileInfo.fTgtDataForkSize = // data fork size
- theCatInfo.hFileInfo.ioFlLgLen;
- theTargetInfoPBPtr->fFileInfo.fTgtRsrcForkSize = // resource fork size
- theCatInfo.hFileInfo.ioFlRLgLen;
- theTargetInfoPBPtr->fFileInfo.fTgtCreationDate = // creation date
- theCatInfo.hFileInfo.ioFlCrDat;
- theTargetInfoPBPtr->fFileInfo.fTgtModDate = // mod date
- theCatInfo.hFileInfo.ioFlMdDat;
- }
-
- }
-
- return theErr;
- }
-